<extend name="./base" />
<block name="pageContent">
    <div class="main-content">
        <!-- 头部面包屑导航条 -->
        <div class="breadcrumbs" id="breadcrumbs">
            <!--导航路径列表-->
            <ul class="breadcrumb no-margin-left">
                <li>
                    <a>管理后台</a>
                </li>
                <li class="action">
                    签到兑换管理
                </li>
            </ul>
        </div>
        <!--页面容器-->
        <div class="page-content">
            <div class="nav-tab" style="position: relative">
                <ul class="nav-tab-title ">
                    <li class="nav-this">兑换记录</li>
                </ul>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <form class="form-horizontal s_input-bgcolor" method="post" action="{$Think.config.DOMAIN_URL}/exchange/index">
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right">状态： </label>
                                <div class="col-sm-8">
                                    <select class="form-control" name="status">
                                        <option value="0">全部状态</option>
                                        <option value="2" <eq name="postArr.status" value="2">selected</eq>>待发货</option>
                                        <option value="3" <eq name="postArr.status" value="3">selected</eq>>已发货</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right"
                                       for="form-field-1-1">用户： </label>
                                <div class="col-sm-8">
                                    <input type="text" id="form-field-1-11" placeholder="请输入用户账号"
                                           class="form-control" name="name" value="{$postArr.name}">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right"
                                       for="form-field-1-1">订单号： </label>
                                <div class="col-sm-8">
                                    <input type="text" id="form-field-1-1" placeholder="请输入用户账号"
                                           class="form-control" name="orderno" value="{$postArr.orderno}">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right">下单时间： </label>
                                <div class="col-sm-8">
                                    <div class="input-daterange input-group">
                                        <input type="text" class="input-sm form-control" placeholder="开始时间"
                                               name="start" id="start" value="{$postArr.start}">
                                            <span class="input-group-addon" style="background: none;border: none;">
																	-
																</span>
                                        <input type="text" class="input-sm form-control" placeholder="结束时间"
                                               name="end" id="end" value="{$postArr.end}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-12 col-md-6 col-sm-12 col-xs-12 pad-b20 text-right">
                            <button type="submit" class="btn "
                                    style="width: 120px; border-radius: 2rem; background: #fba40a!important;border-color: #fba40a;margin-left: 20px;">
                                查询
                            </button>
                        </div>
                    </form>
                    <div class="space"></div>
                    <div class="row">
                        <div class="col-xs-12">
                            <table id="sample-table-1"
                                   class="table table-hover">
                                <thead>
                                <tr>
                                    <th class="center">订单号</th>
                                    <th class="center">用户</th>
                                    <th class="center">兑换商品</th>
                                    <th class="center">支付金币</th>
                                    <th class="center">支付金额(¥)</th>
                                    <th class="center">下单时间</th>
                                    <th class="center">付款时间</th>
                                    <th class="center">收货人</th>
                                    <th class="center">物流</th>
                                    <th class="center">状态</th>
                                    <th class="center">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <empty name="resList">
                                    <tr class="s_tr-vertical">
                                        <td colspan="11" class="center" style="color: red;">没有查询到结果</td>
                                    </tr>
                                </empty>
                                <volist  name="resList" id="vo">
                                    <tr class="s_tr-vertical">
                                        <td class="center">{$vo.order_no}</td>
                                        <td class="center">{$uRes[$vo[uid]].tname}<br/>{$uRes[$vo[uid]].rname}</td>
                                        <td class="center clearfix" width="18%">
                                            <img src="{$oeRes[$vo[id]][goods_sku][gpic]}?x-oss-process=image/resize,m_pad,h_90,w_90" alt="" width="90" height="90" class="pull-left">
                                            <span class="pull-left width-50 margin-left4">{$oeRes[$vo[id]][goods_sku][gname]}</span>
                                        </td>
                                        <td class="center">{$vo.pay_coin}</td>
                                        <td class="center">{$vo.pay_money}</td>
                                        <td class="center">{$vo.addtime}</td>
                                        <td class="center">{$vo.paytime}</td>
                                        <td class="center">{$oeRes[$vo[id]][rcp_sku][tel]} ({$oeRes[$vo[id]][rcp_sku][uname]}) <br/>{$oeRes[$vo[id]][rcp_sku][address]}</td>
                                        <td class="center">{$oeRes[$vo[id]][express_name]}<br/>{$oeRes[$vo[id]][express_no]}</td>
                                        <eq name="vo.status" value="2">
                                            <td class="center" style="color: red">待发货</td>
                                        <else />
                                            <td class="center" style="color: green">已发货</td>
                                        </eq>
                                        <td class="center s_order-fun s_order-funmargin">
                                            <eq name="vo.status" value="2">
                                                <span onclick="addExpress({$vo.id},'{$vo.order_no}')">添加物流</span>
                                            <else />
                                                <span onclick="addExpress({$vo.id},'{$vo.order_no}')">编辑物流</span>
                                            </eq>
                                        </td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="text-center">
                {$pageShow}
            </div>
        </div>
    </div>

    <script>
        laydate.render({
            elem: '#start' //指定元素
        });
        laydate.render({
            elem: '#end' //指定元素
        });
        //添加物流
        function addExpress(oid,orderNo) {
            $.popup({
                type: 2,
                title: '订单（'+orderNo+'）物流信息',
                main:[
                    {key:'快递公司：',val:'input',hint:'请输入快递公司'},
                    {key:'快递单号：',val:'input',hint:'请输入快递单号'}
                ],
                callback: function (json,dom) {
                    console.log(json);
                    var expressName = json.key0;
                    var expressNo = json.key1;
                    if(!expressName || !expressNo){
                        return;
                    }
                    $.post('/exchange/addExpress',{oid:oid,expressName:expressName,expressNo:expressNo},function(data){
                        location.href = '/exchange/index?p='+{$page}+'&tip=1';
                    });
                }
            })
        }
    </script>
</block>